home *** CD-ROM | disk | FTP | other *** search
/ Champak 130 / Vol 130.iso / games / target_s.swf / scripts / assets / buildings / building3.as < prev    next >
Encoding:
Text File  |  2008-11-13  |  6.4 KB  |  222 lines

  1. package assets.buildings
  2. {
  3.    import assets.buildings.parts.*;
  4.    import flash.display.*;
  5.    import flash.events.*;
  6.    import flash.geom.Point;
  7.    
  8.    [Embed(source="/_assets/assets.swf", symbol="assets.buildings.building3")]
  9.    public class building3 extends MovieClip
  10.    {
  11.        
  12.       
  13.       public var pp:Point;
  14.       
  15.       public var deep:Number = 30;
  16.       
  17.       public var space:Number = 10;
  18.       
  19.       public var scope:Object;
  20.       
  21.       public var planes:Array;
  22.       
  23.       public var dist:Number;
  24.       
  25.       public var wide:Number = 154;
  26.       
  27.       public function building3(param1:*)
  28.       {
  29.          pp = new Point(350 + 150,200);
  30.          deep = 30;
  31.          wide = 154;
  32.          space = 10;
  33.          planes = new Array();
  34.          super();
  35.          setData();
  36.          scope = param1;
  37.          addEventListener(Event.ENTER_FRAME,render);
  38.          addEventListener(Event.REMOVED_FROM_STAGE,onRemove);
  39.       }
  40.       
  41.       public function setData() : *
  42.       {
  43.          planes.push({
  44.             "A":new Point(154,0),
  45.             "B":new Point(154,-20),
  46.             "cl":10053171,
  47.             "al":1
  48.          });
  49.          planes.push({
  50.             "A":new Point(150,-20),
  51.             "B":new Point(154,-20),
  52.             "cl":13408614,
  53.             "al":1
  54.          });
  55.          planes.push({
  56.             "A":new Point(150,-20),
  57.             "B":new Point(150,-450),
  58.             "cl":4399361,
  59.             "al":1
  60.          });
  61.          planes.push({
  62.             "A":new Point(153,-150),
  63.             "B":new Point(153,-160),
  64.             "cl":10053171,
  65.             "al":1
  66.          });
  67.          planes.push({
  68.             "A":new Point(150,-150),
  69.             "B":new Point(153,-150),
  70.             "cl":6697728,
  71.             "al":1
  72.          });
  73.          planes.push({
  74.             "A":new Point(153,-300),
  75.             "B":new Point(153,-310),
  76.             "cl":10053171,
  77.             "al":1
  78.          });
  79.          planes.push({
  80.             "A":new Point(150,-300),
  81.             "B":new Point(153,-300),
  82.             "cl":6697728,
  83.             "al":1
  84.          });
  85.          planes.push({
  86.             "A":new Point(153,-450),
  87.             "B":new Point(153,-460),
  88.             "cl":10053171,
  89.             "al":1
  90.          });
  91.          planes.push({
  92.             "A":new Point(150,-450),
  93.             "B":new Point(153,-450),
  94.             "cl":6697728,
  95.             "al":1
  96.          });
  97.          planes.push({
  98.             "A":new Point(-154,0),
  99.             "B":new Point(-154,-20),
  100.             "cl":10053171,
  101.             "al":1
  102.          });
  103.          planes.push({
  104.             "A":new Point(-150,-20),
  105.             "B":new Point(-154,-20),
  106.             "cl":13408614,
  107.             "al":1
  108.          });
  109.          planes.push({
  110.             "A":new Point(-150,-20),
  111.             "B":new Point(-150,-450),
  112.             "cl":4399361,
  113.             "al":1
  114.          });
  115.          planes.push({
  116.             "A":new Point(-153,-150),
  117.             "B":new Point(-153,-160),
  118.             "cl":10053171,
  119.             "al":1
  120.          });
  121.          planes.push({
  122.             "A":new Point(-150,-150),
  123.             "B":new Point(-153,-150),
  124.             "cl":6697728,
  125.             "al":1
  126.          });
  127.          planes.push({
  128.             "A":new Point(-153,-300),
  129.             "B":new Point(-153,-310),
  130.             "cl":10053171,
  131.             "al":1
  132.          });
  133.          planes.push({
  134.             "A":new Point(-150,-300),
  135.             "B":new Point(-153,-300),
  136.             "cl":6697728,
  137.             "al":1
  138.          });
  139.          planes.push({
  140.             "A":new Point(-153,-450),
  141.             "B":new Point(-153,-460),
  142.             "cl":10053171,
  143.             "al":1
  144.          });
  145.          planes.push({
  146.             "A":new Point(-150,-450),
  147.             "B":new Point(-153,-450),
  148.             "cl":6697728,
  149.             "al":1
  150.          });
  151.       }
  152.       
  153.       public function onRemove(param1:Event) : *
  154.       {
  155.          removeEventListener(Event.ENTER_FRAME,render);
  156.          removeEventListener(Event.REMOVED_FROM_STAGE,onRemove);
  157.       }
  158.       
  159.       public function drawPlane(param1:*) : *
  160.       {
  161.          var _loc2_:* = undefined;
  162.          var _loc3_:* = undefined;
  163.          var _loc4_:* = undefined;
  164.          var _loc5_:* = undefined;
  165.          var _loc6_:* = undefined;
  166.          var _loc7_:* = undefined;
  167.          var _loc8_:* = undefined;
  168.          var _loc9_:* = undefined;
  169.          var _loc10_:* = undefined;
  170.          var _loc11_:* = undefined;
  171.          var _loc12_:* = undefined;
  172.          var _loc13_:* = undefined;
  173.          _loc2_ = new Point(pp.x - (x + param1.A.x),pp.y - y);
  174.          _loc3_ = Math.atan2(_loc2_.y,_loc2_.x);
  175.          _loc4_ = -deep * (1 / Math.tan(_loc3_));
  176.          _loc5_ = new Point(pp.x - (x + param1.A.x),pp.y - (y + param1.A.y));
  177.          _loc6_ = Math.atan2(_loc5_.y,_loc5_.x);
  178.          _loc7_ = _loc4_ * Math.tan(_loc6_);
  179.          _loc8_ = new Point(pp.x - (x + param1.B.x),pp.y - y);
  180.          _loc9_ = Math.atan2(_loc8_.y,_loc8_.x);
  181.          _loc10_ = -deep * (1 / Math.tan(_loc9_));
  182.          _loc11_ = new Point(pp.x - (x + param1.B.x),pp.y - (y + param1.B.y));
  183.          _loc12_ = Math.atan2(_loc11_.y,_loc11_.x);
  184.          _loc13_ = _loc10_ * Math.tan(_loc12_);
  185.          graphics.beginFill(param1.cl,param1.al);
  186.          graphics.moveTo(param1.A.x,param1.A.y);
  187.          graphics.lineTo(param1.A.x + _loc4_,param1.A.y + _loc7_);
  188.          graphics.lineTo(param1.B.x + _loc10_,param1.B.y + _loc13_);
  189.          graphics.lineTo(param1.B.x,param1.B.y);
  190.          graphics.lineTo(param1.A.x,param1.A.y);
  191.          graphics.endFill();
  192.       }
  193.       
  194.       public function render(param1:Event) : *
  195.       {
  196.          var _loc2_:* = undefined;
  197.          graphics.clear();
  198.          _loc2_ = 0;
  199.          while(_loc2_ < planes.length)
  200.          {
  201.             drawPlane(planes[_loc2_]);
  202.             _loc2_++;
  203.          }
  204.       }
  205.       
  206.       public function addElements() : *
  207.       {
  208.          var _loc1_:* = undefined;
  209.          var _loc2_:* = undefined;
  210.          var _loc3_:* = undefined;
  211.          var _loc4_:MovieClip = null;
  212.          _loc1_ = new Point(pp.x - x,pp.y - y);
  213.          _loc2_ = Math.atan2(_loc1_.y,_loc1_.x);
  214.          _loc3_ = 1 / Math.tan(_loc2_);
  215.          (_loc4_ = new railing1()).x = x + -45 + _loc4_.deep * _loc3_;
  216.          _loc4_.y = 340;
  217.          scope.elementArray.push(_loc4_);
  218.          scope.element.addChild(_loc4_);
  219.       }
  220.    }
  221. }
  222.